package com.example.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.example.shop.pojo.UserAddressBook;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserAddressBookMapper extends BaseMapper<UserAddressBook> {

    @Update("<script>" +
            "UPDATE r_user_address_book " +
            "set " +
            "<if test = 'et.linkmanPicture != null'>" +
                "linkman_picture = #{et.linkmanPicture}," +
            "</if>" +
            "<if test = 'et.linkmanName != null'>" +
                "linkman_name = #{et.linkmanName}," +
            "</if>" +
            "<if test = 'et.linkmanPhone != null'>" +
                "linkman_phone = #{et.linkmanPhone}," +
            "</if>" +
            "<if test = 'et.linkmanArea != null'>" +
                "linkman_area = #{et.linkmanArea}," +
            "</if>" +
            "<if test = 'et.detailedAddress != null'>" +
                "detailed_address = #{et.detailedAddress}," +
            "</if>" +
            "<if test = 'et.linkmanLongitude != null'>" +
                "linkman_longitude = #{et.linkmanLongitude}," +
            "</if>" +
            "<if test = 'et.linkmanLatitude != null'>" +
                "linkman_latitude = #{et.linkmanLatitude}," +
            "</if>" +
            "user_id = user_id " +
            "where linkman_id = ${et.linkmanId}"+
            "</script>")
    int updateNotNull(@Param(Constants.ENTITY) UserAddressBook modifyInfo);
}
